package org.strangewt.demo.composit;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IViewPart;
import org.strangewt.demo.Activator;
import org.strangewt.demo.view.ViewContent;
import org.strangewt.widgets.CompositeBase;

public class CompositeList extends CompositeBase implements SelectionListener {

	private Button btRegistries;
	private Button btCompBase;
	private Button btCompCompositeViewer;
	
	public CompositeList(Composite parent, int style) {
		super(parent, style);
		
		createControl(this);
	}
	
	private void createControl(Composite parent) {
	
		RowLayout layout = new RowLayout();
		layout.type = SWT.VERTICAL;
		layout.fill = true;
		parent.setLayout(layout);
		
		btRegistries = createButton(parent, "Registries", this);
		
		btCompBase = createButton(parent, "CompositeBase", this);
		
		btCompCompositeViewer = createButton(parent, "CompositeViewer", this);
	}

	
	// SelectionListener /////////////////////
	
	@Override
	public void widgetSelected(SelectionEvent e) {
		
		ViewContent view = (ViewContent) Activator.getDefault().getView(ViewContent.ID);
		
		if(e.widget == btRegistries) {
			view.showComposite(CompositeRegistries.class);
		}
		if(e.widget == btCompBase) {
			view.showComposite(CompositeBaseShowcase.class);
		}
		if(e.widget == btCompCompositeViewer) {
			view.showComposite(CompositeCompositeViewer.class);
		}
	}

	@Override
	public void widgetDefaultSelected(SelectionEvent e) {
		
	}

}
